from src.Utils.index import colored_text
from flask import g

class StoreDao:
    def __init__(self):
        pass
    
    def get_storeinfo_by_id(self,id: int):
        """
        根据id查询店铺信息
        
        参数
            id: 店铺id
        
        返回
            data: 店铺信息
        """
        db = g.db
        cursor = db.cursor() if db is not None else None
        sql = f"SELECT * FROM Store WHERE id = {id}"
        try:
            cursor.execute(sql)
            result = cursor.fetchone()
            cursor.close()
            return result
        except:
            print(colored_text("------查询失败-----","red"))
            return None
        finally:
            if cursor is not None:
                cursor.close()